﻿using UnityEngine;
using System.Collections;

public class GuideLogic : MonoBehaviour
{
    public Transform guideMark;

    Vector3 guideLocation;

    public Vector2 offSetPos;
	
	Vector3 originalScale;

    void Start()
    {
        guideLocation = guideMark.localPosition;
		originalScale = guideMark.localScale;
    }

    // Update is called once per frame
    void LateUpdate()
    {
    }

    /// <summary>
    /// 设置箭头位置及方向
    /// </summary>
    /// <param name="pos">位置</param>
    /// <param name="direction">1:上2:下3:左4:右</param>
    /// <param name="offSet">偏移量</param>
    public void setGuidePos(GameObject obj,int direction,Vector3 offSet)
    {
        setGuideVisible(true);
        offSetPos = offSet;
        guideMark.rotation = Quaternion.identity;
        guideMark.parent = obj.transform;
		
		guideMark.localPosition = offSet;
        
        switch (direction)
        {
            case 1:
                guideMark.Rotate(0,0,180,Space.Self);
                break;
            case 2:
                break;
            case 3:
                guideMark.Rotate(0, 0, -90, Space.Self);
                break;
            case 4:
                guideMark.Rotate(180, 0, 90, Space.Self);
                break;
        }
    }

    public void setGuideVisible(bool visible)
    {
		if(visible == false){
			guideMark.localScale = Vector3.zero;
		} else {
			guideMark.localScale = originalScale;
		}
    }
}
